package generics;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class Person <T>{

    T data;
    public Person() {
        Type type = getClass().getGenericSuperclass();
        System.out.println("类型："+type);
        Class<?> superclass = getClass().getSuperclass();
        System.out.println("类型："+superclass);
        if (type instanceof ParameterizedType){
            System.out.println("有泛型");
            Type[] types = ((ParameterizedType) type).getActualTypeArguments();
            System.out.println(types[0]);
        }
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
